package co.edu.usbcali.modelo.dto;

import co.edu.usbcali.modelo.ActaSupervision;
import co.edu.usbcali.presentation.backEndBeans.ActaSupervisionView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class ActaSupervisionDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String actividadSuper;
    private String codPra_Practicante;
    private String codSuper;
    private Date fechaSuper;
    private boolean rowSelected = false;
    private ActaSupervisionView actaSupervisionView;
    private ActaSupervision actaSupervision;

    public ActaSupervision getActaSupervision() {
        return actaSupervision;
    }

    public String listener_update(ActionEvent e) {
        try {
            actaSupervisionView.action_modifyWitDTO(((actividadSuper == null) ||
                actividadSuper.equals("")) ? null : new String(actividadSuper),
                ((codSuper == null) || codSuper.equals("")) ? null
                                                            : new Long(codSuper),
                ((fechaSuper == null) || fechaSuper.equals("")) ? null
                                                                : fechaSuper,
                ((codPra_Practicante == null) || codPra_Practicante.equals(""))
                ? null : new Long(codPra_Practicante));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        codSuper = actaSupervision.getCodSuper().toString();
        actividadSuper = (actaSupervision.getActividadSuper() != null)
            ? actaSupervision.getActividadSuper().toString() : null;
        fechaSuper = actaSupervision.getFechaSuper();
        codPra_Practicante = (actaSupervision.getPracticante().getCodPra() != null)
            ? actaSupervision.getPracticante().getCodPra().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Customer details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        codSuper = actaSupervision.getCodSuper().toString();
        actividadSuper = (actaSupervision.getActividadSuper() != null)
            ? actaSupervision.getActividadSuper().toString() : null;
        fechaSuper = actaSupervision.getFechaSuper();
        codPra_Practicante = (actaSupervision.getPracticante().getCodPra() != null)
            ? actaSupervision.getPracticante().getCodPra().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setActaSupervision(ActaSupervision actaSupervision) {
        this.actaSupervision = actaSupervision;
    }

    public ActaSupervisionView getActaSupervisionView() {
        return actaSupervisionView;
    }

    public void setActaSupervisionView(ActaSupervisionView actaSupervisionView) {
        this.actaSupervisionView = actaSupervisionView;
    }

    public String getActividadSuper() {
        return actividadSuper;
    }

    public void setActividadSuper(String actividadSuper) {
        this.actividadSuper = actividadSuper;
    }

    public String getCodPra_Practicante() {
        return codPra_Practicante;
    }

    public void setCodPra_Practicante(String codPra_Practicante) {
        this.codPra_Practicante = codPra_Practicante;
    }

    public Date getFechaSuper() {
        return fechaSuper;
    }

    public void setFechaSuper(Date fechaSuper) {
        this.fechaSuper = fechaSuper;
    }

    public String getCodSuper() {
        return codSuper;
    }

    public void setCodSuper(String codSuper) {
        this.codSuper = codSuper;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
